import ArraySort.MergeSort;

import java.util.Comparator;
import java.util.Random;


public class Test {
    public <T> void display(T[] arr) {
        for (T a : arr) {
            System.out.println(a.toString() + " ");
        }
    }

    public void display(int[] arr) {
        for (int a : arr) {
            System.out.println(a + " ");
        }
    }

    public static void main(String[] args) {

        Test b = new Test();
        MergeSort test = new MergeSort();
        Student[] stu = new Student[5];
        Clerk[] clk = new Clerk[5];
        Random rand = new Random();
        Integer id[] = new Integer[5];
        for (int i = 0; i < 5; i++) {
            id[i] = rand.nextInt(1000);
        }
        String stuName[] = {"Alex", "Celler", "Becall", "Ewag", "Dike"};
        String clkName[] = {"Creen", "Ded", "Ahite", "Bellow", "Eink"};
        for (int i = 0; i < 5; i++) {
            stu[i] = new Student(id[i], stuName[i]);
            clk[i] = new Clerk(clkName[i]);
        }
        System.out.println("The Clerk before sorting: ");
        b.display(clk);
        System.out.println();
        test.mergeSort(clk);   //第一种参数
        System.out.println("The Clerk after sorting: ");
        b.display(clk);
        System.out.println("-------------------------------------------------");


        System.out.println("The Student before sorting: ");
        b.display(stu);
        System.out.println();
        test.mergeSort(stu, new Comparator<Comparable>() {//第二种参数
            @Override
            public int compare(Comparable o1, Comparable o2) {
                return ((Student) o1).getId().compareTo(((Student) o2).getId());
            }
        });
        System.out.println("The Student after sorting: ");
        b.display(stu);


    }


}
